package com.blue.integration.pay.swift;

import com.blue.integration.pay.PayNotify;
import com.blue.integration.pay.PayState;

/**
 * 威富通支付异步通知
 *
 * @author zhengjin
 * @since 1.0 2017年12月14日
 */
public class XmlSwiftNotify
{
	private String service; // 接口类型
	private String appid; //公众账号 ID
	private String charset; //编码
	private String mchId; //商户号
	private String nonceStr; //随机字符串
	private String resultCode; // 0 标识交易成功  非0标识交易失败
	private String sign; //签名
	private String signType;  //签名方式
	private String status;  //0 表示成功  非0 表示失败  此状态只标识通信成功，而非交易状态
	private String tokenId; //动态口令
	private String version; //版本号
	private String errCode; //错误代码
	private String errMsg; //错误代码描述
	private String message; // 返回信息，如非空，为错误原因签名失败参数格式校验错误
	private String openid; // 用户openid
	private String outTransactionId; // 微信支付订单号
	private String transactionId;  //威富通订单号
	private String outTradeNo; //商户订单号
	private String tradeType; //支付类型
	private Integer totalFee; // 支付金额
	private String timeEnd;    //支付完成时间
	private Integer payResult;   //交付结果
	private String bankType; // 银行类型
	private String bankBillno; // 银行订单号

	public XmlSwiftNotify()
	{
	}

	public PayNotify toNotify()
	{
		PayNotify notify = new PayNotify();
		if ("0".equals(status))
		{
			if ("0".equals(resultCode))
			{
				notify.setSuccess(true);
			}
			else
			{
				notify.setSuccess(false);
			}
			notify.setCode(errCode);
			notify.setMessage(errMsg);
		}
		else
		{
			notify.setSuccess(false);
			notify.setCode(status);
			notify.setMessage(message);
		}
		if (payResult != null && payResult == 0)
		{
			notify.setState(PayState.SUCCESS);
		}
		else
		{
			notify.setState(PayState.FAIL);
		}
		notify.setMoney(totalFee.doubleValue() / 100);
		notify.setOrderNo(outTradeNo);
		notify.setSeq(transactionId);
		notify.setReturnString("success");
		return notify;
	}

	public String getService()
	{
		return service;
	}

	public void setService(String service)
	{
		this.service = service;
	}

	public String getAppid()
	{
		return appid;
	}

	public void setAppid(String appid)
	{
		this.appid = appid;
	}

	public String getCharset()
	{
		return charset;
	}

	public void setCharset(String charset)
	{
		this.charset = charset;
	}

	public String getMchId()
	{
		return mchId;
	}

	public void setMchId(String mchId)
	{
		this.mchId = mchId;
	}

	public String getNonceStr()
	{
		return nonceStr;
	}

	public void setNonceStr(String nonceStr)
	{
		this.nonceStr = nonceStr;
	}

	public String getResultCode()
	{
		return resultCode;
	}

	public void setResultCode(String resultCode)
	{
		this.resultCode = resultCode;
	}

	public String getSign()
	{
		return sign;
	}

	public void setSign(String sign)
	{
		this.sign = sign;
	}

	public String getSignType()
	{
		return signType;
	}

	public void setSignType(String signType)
	{
		this.signType = signType;
	}

	public String getStatus()
	{
		return status;
	}

	public void setStatus(String status)
	{
		this.status = status;
	}

	public String getTokenId()
	{
		return tokenId;
	}

	public void setTokenId(String tokenId)
	{
		this.tokenId = tokenId;
	}

	public String getVersion()
	{
		return version;
	}

	public void setVersion(String version)
	{
		this.version = version;
	}

	public String getErrCode()
	{
		return errCode;
	}

	public void setErrCode(String errCode)
	{
		this.errCode = errCode;
	}

	public String getErrMsg()
	{
		return errMsg;
	}

	public void setErrMsg(String errMsg)
	{
		this.errMsg = errMsg;
	}

	public String getMessage()
	{
		return message;
	}

	public void setMessage(String message)
	{
		this.message = message;
	}

	public String getOpenid()
	{
		return openid;
	}

	public void setOpenid(String openid)
	{
		this.openid = openid;
	}

	public String getOutTransactionId()
	{
		return outTransactionId;
	}

	public void setOutTransactionId(String outTransactionId)
	{
		this.outTransactionId = outTransactionId;
	}

	public String getTransactionId()
	{
		return transactionId;
	}

	public void setTransactionId(String transactionId)
	{
		this.transactionId = transactionId;
	}

	public String getOutTradeNo()
	{
		return outTradeNo;
	}

	public void setOutTradeNo(String outTradeNo)
	{
		this.outTradeNo = outTradeNo;
	}

	public String getTradeType()
	{
		return tradeType;
	}

	public void setTradeType(String tradeType)
	{
		this.tradeType = tradeType;
	}

	public Integer getTotalFee()
	{
		return totalFee;
	}

	public void setTotalFee(Integer totalFee)
	{
		this.totalFee = totalFee;
	}

	public String getTimeEnd()
	{
		return timeEnd;
	}

	public void setTimeEnd(String timeEnd)
	{
		this.timeEnd = timeEnd;
	}

	public Integer getPayResult()
	{
		return payResult;
	}

	public void setPayResult(Integer payResult)
	{
		this.payResult = payResult;
	}

	public String getBankType()
	{
		return bankType;
	}

	public void setBankType(String bankType)
	{
		this.bankType = bankType;
	}

	public String getBankBillno()
	{
		return bankBillno;
	}

	public void setBankBillno(String bankBillno)
	{
		this.bankBillno = bankBillno;
	}
}
